package cn.e4j.modular.api.controller;
import cn.e4j.core.dto.impl.Dto;
import cn.e4j.core.dto.requestDtoResolver.DtoParam;
import cn.e4j.core.dto.requestDtoResolver.DtoWapper;
import cn.e4j.core.reqres.response.ErrorResponseData;
import cn.e4j.core.reqres.response.ResponseData;
import cn.e4j.core.reqres.response.SuccessResponseData;
import cn.e4j.modular.api.service.MmrService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by wenchuan on 2018/4/17.
 */
@RestController
@RequestMapping("api/wx/mmr")
public class MmrController {

    private static Logger logger = LoggerFactory.getLogger(MmrController.class);


    @Autowired
    private MmrService mmrService;


    /**
     * 获取标准收费项目
     */
    @RequestMapping(value = "getMmrcList")
    public ResponseData getMmrcList(@DtoParam DtoWapper wapper) {
        Dto inDto = wapper.getDto();
        List<Dto> list = new ArrayList<>();
        try {
            inDto.put("MMRCENT",inDto.getString("ENT"));
            inDto.put("MMRCL002", '2');
            list = mmrService.getMmrcList(inDto);
        } catch (Exception e) {
            e.printStackTrace();
            return new ErrorResponseData("系统出错");
        }
        return new SuccessResponseData(list);
    }

    /**
     * 获取客户对服务的评价
     */
    @RequestMapping(value = "getFwpjList")
    public ResponseData getFwpjList(@DtoParam DtoWapper wapper) {
        Dto inDto = wapper.getDto();
        List<Dto> list = new ArrayList<>();
        try {
            inDto.put("MMRCENT",inDto.getString("ENT"));
            list = mmrService.getFwpjOfCustomer(inDto);
        } catch (Exception e) {
            e.printStackTrace();
            return new ErrorResponseData("系统出错");
        }
        return new SuccessResponseData(list);
    }



}
